package com.spsoft.vatoutinv.controller.matchflow;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.controller.BaseController;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.vatoutinv.model.dto.matchflow.VmsMatchFlowSelectPageDto;
import com.spsoft.vatoutinv.model.dto.matchflow.VmsSelectItemFlowPageDto;
import com.spsoft.vatoutinv.model.vo.matchflow.VmsMatchFlowSelectVo;
import com.spsoft.vatoutinv.model.vo.vmstransactionflowinvoice.VmsTransactionFlowInvoicePageVo;
import com.spsoft.vatoutinv.service.matchflow.VmsMatchFlowSelectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 手工匹配流水查询 前端控制器
 * </p>
 *
 * @author chenxudong
 * @since 2024-06-28
 */
@RestController
@Api(tags = {"手工匹配流水查询管理"})
@RequestMapping("/matchFlowSelect")
@RequiredArgsConstructor
@Validated
@Slf4j
public class VmsMatchFlowSelectController extends BaseController {

    public static final String LOG_MSG = "(手工匹配流水查询控制层)";

    private final VmsMatchFlowSelectService vmsMatchFlowSelectService;

    @ApiOperation("手工匹配流水查询主页面-分页查询")
    @AnonymousAccess(value = "/getPage", method = RequestMethod.POST, permissionCode = "")
    @Log(value = "分页查询", type = LogActionType.SELECT, menuName = LogMenuEnum.VMS_MATCH_FLOW_SELECT)
    public Result<IPage<VmsMatchFlowSelectVo>> getPage(@RequestBody @Validated VmsMatchFlowSelectPageDto pageDto) {
        log.info("{}分页查询入参：{}", LOG_MSG, JSONObject.toJSONString(pageDto));
        return vmsMatchFlowSelectService.getPage(pageDto);
    }

    @ApiOperation("手工匹配流水查询主页面-数据导出")
    @AnonymousAccess(value = "/export", method = RequestMethod.POST, permissionCode = "")
    @Log(value = "数据导出", type = LogActionType.DOWNLOAD, menuName = LogMenuEnum.VMS_MATCH_FLOW_SELECT)
    public void export(@RequestBody @Validated VmsMatchFlowSelectPageDto pageDto, HttpServletResponse response) {
        log.info("{}数据导出入参：{}", LOG_MSG, JSONObject.toJSONString(pageDto));
        vmsMatchFlowSelectService.export(pageDto, response);
    }

    @ApiOperation("查询明细已匹配的交易流水-分页查询")
    @AnonymousAccess(value = "/queryFlowByItem", method = RequestMethod.POST, permissionCode = "")
    @Log(value = "查询明细已匹配的交易流水-分页查询", type = LogActionType.SELECT, menuName = LogMenuEnum.VMS_MATCH_FLOW_SELECT)
    public Result<IPage<VmsTransactionFlowInvoicePageVo>> queryFlowByItem(@RequestBody @Validated VmsSelectItemFlowPageDto pageDto) {
        log.info("{}查询明细已匹配的交易流水，分页查询入参：{}", LOG_MSG, JSONObject.toJSONString(pageDto));
        return vmsMatchFlowSelectService.queryFlowByItem(pageDto);
    }

}